<template>
  <BasicModal v-bind="$attrs" destroyOnClose @ok="handleSubmit" @register="register" title="设置openid"
    :helpMessage="['填写密文或扫码填写', '']">
    <InputTextArea :rows="10" laceholder="授权密文" v-model:value="encode" allowClear />
  </BasicModal>
</template>
<script lang="ts" setup>
import { ref, } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { Input } from 'ant-design-vue';
import { setOpenid } from '../NurseNurses.api';

const InputTextArea = Input.TextArea

const emit = defineEmits(['success']);

const encode = ref()

const record = ref()

const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
  record.value = data.record
});
//表单提交事件
async function handleSubmit() {
  try {

    setModalProps({ confirmLoading: true });
    //提交表单
    await setOpenid({ encode: encode.value, id: record.value.id });

    encode.value = undefined
    //关闭弹窗
    closeModal();
    //刷新列表
    emit('success');
  } finally {
    setModalProps({ confirmLoading: false });
  }
}
</script>
